﻿Imports DTO
Imports BUS
Public Class fmQuiDinh

    Private Sub ButtonThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonThoat.Click
        Me.Close()
    End Sub

    Private Sub fmQuiDinh_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ds As List(Of QuiDinhDTO)
        Dim bus As New QuiDinhBUS()
        ds = bus.LayDanhSach()
        dgvQuiDinh.Rows.Clear()
        For i As Integer = 0 To ds.Count - 1
            dgvQuiDinh.Rows.Add(ds(i).Ma, ds(i).SLTD, ds(i).ChiSoPhuThu, ds(i).HS)
        Next
    End Sub

    Private Sub btnCapNhat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCapNhat.Click
        'If (txttendoi.Text = "") Then

        '    MessageBox.Show("Bạn hãy chọn Loại phòng cần cập nhật", "Chú ý !")

        'End If

        Dim qdDTO As New QuiDinhDTO()
        qdDTO.SLTD = Integer.Parse(txtsltd.Text.Trim())
        qdDTO.ChiSoPhuThu = Single.Parse(txtcspt.Text.Trim())
        qdDTO.HS = Single.Parse(txths.Text.Trim())
        qdDTO.Ma = Integer.Parse(txtMa.Text.Trim())
        'goi BUS
        ' Dim kq As Integer
        Dim bus As New QuiDinhBUS()
        bus.CapNhatQuiDinh(qdDTO)
        fmQuiDinh_Load(sender, e)

    End Sub

    Private Sub dgvQuiDinh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgvQuiDinh.Click
        Dim temp As Integer
        temp = dgvQuiDinh.CurrentRow.Index
        txtMa.Text = dgvQuiDinh.Rows.Item(temp).Cells("STT").Value.ToString()
        txtsltd.Text = dgvQuiDinh.Rows.Item(temp).Cells("SoLuongToiDa").Value.ToString()
        txtcspt.Text = dgvQuiDinh.Rows.Item(temp).Cells("ChiSoPhuThu").Value.ToString()
        txths.Text = dgvQuiDinh.Rows.Item(temp).Cells("HeSo").Value.ToString()
        

    End Sub
End Class